gl renderer: More color matrix state tracking
authorTimm Bäder <mail@baedert.org>
Fri, 24 Jul 2020 15:29:22 +0000 (17:29 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 28 Jul 2020 03:34:12 +0000 (05:34 +0200)
gsk/gl/gskglrenderer.c
gsk/gl/gskglrenderops.c
gsk/gl/opbuffer.h

index 78242df74faa332a763b4bfe1cc0cca492e97981..219ea96636ed65cfdea0a276f616e41fb4ef1b7a 100644 (file)
@@ -2585,13 +2585,16 @@ apply_color_matrix_op (const Program       *program,
                        const OpColorMatrix *op)
 {
   float mat[16];
-  float vec[4];
   OP_PRINT (" -> Color Matrix");
   graphene_matrix_to_float (op->matrix, mat);
   glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
 
-  graphene_vec4_to_float (op->offset, vec);
-  glUniform4fv (program->color_matrix.color_offset_location, 1, vec);
+  if (op->offset.send)
+    {
+      float vec[4];
+      graphene_vec4_to_float (op->offset.value, vec);
+      glUniform4fv (program->color_matrix.color_offset_location, 1, vec);
+    }
 }
 
 static inline void
index f710041cef07c3793d93e28e9e30317deb4cf44a..bcee21a6596825d597149cb2868e27d033aedfce 100644 (file)
@@ -618,21 +618,32 @@ ops_set_color_matrix (RenderOpBuilder         *builder,
 {
   ProgramState *current_program_state = get_current_program_state (builder);
   OpColorMatrix *op;
+  bool offset_equal;
+
+  offset_equal = memcmp (offset,
+                         &current_program_state->color_matrix.offset,
+                         sizeof (graphene_vec4_t)) == 0;
 
   if (memcmp (matrix,
               &current_program_state->color_matrix.matrix,
               sizeof (graphene_matrix_t)) == 0 &&
-      memcmp (offset,
-              &current_program_state->color_matrix.offset,
-              sizeof (graphene_vec4_t)) == 0)
+      offset_equal)
     return;
 
   current_program_state->color_matrix.matrix = *matrix;
-  current_program_state->color_matrix.offset = *offset;
 
   op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
   op->matrix = matrix;
-  op->offset = offset;
+
+  if (!offset_equal)
+    {
+      op->offset.value = offset;
+      op->offset.send = TRUE;
+
+      current_program_state->color_matrix.offset = *offset;
+    }
+  else
+    op->offset.send = FALSE;
 }
 
 void
index 76609c82a170b051a058c6315ae98fc2a894cf97..8637d79657a985e8716ddc07f5635dae9a23b061 100644 (file)
@@ -46,6 +46,7 @@ typedef struct { float value; guint send: 1; }    FloatUniformValue;
 typedef struct { float value[2]; guint send: 1; } Float2UniformValue;
 typedef struct { GskRoundedRect value; guint send: 1; guint send_corners: 1; } RRUniformValue;
 typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue;
+typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue;
 
 /* OpNode are allocated within OpBuffer.pos, but we keep
  * a secondary index into the locations of that buffer
@@ -137,7 +138,7 @@ typedef struct
 typedef struct
 {
   const graphene_matrix_t *matrix;
-  const graphene_vec4_t *offset;
+  Vec4UniformValue offset;
 } OpColorMatrix;
 
 typedef struct